﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace IllustrateCsharp7_ch21_netframework
{
    class SynchronizationMethod
    {

        static void _Main(string[] args)
         {
            Console.WriteLine($"头部已执行，当前主线程Id为：{Thread.CurrentThread.ManagedThreadId}");
            string result = SayHi("jack");
            Console.WriteLine(result);
            Console.WriteLine($"尾部已执行，当前主线程Id为：{Thread.CurrentThread.ManagedThreadId}");
            Console.ReadKey();
        }
         static string SayHi(string name)
         {
             Task.Delay(2000).Wait();//异步等待2s
             Console.WriteLine($"SayHi执行，当前线程Id为：{Thread.CurrentThread.ManagedThreadId}");
             return $"Hello,{name}";         }
    }
}
